package com.gamefx.resource
{
	import flash.system.LoaderContext;

	public class LoaderManager
	{
		public static const defaultEstimatedBytes:uint = 200000;

		public static const PRIORITY_HIGH:int = 0;
		public static const PRIORITY_MEDIUM:int = 1;
		public static const PRIORITY_LOW:int = 2;

		public static var defaultContext:LoaderContext;
		
		private static var _impl:LoaderCore;

		private static function get impl():LoaderCore
		{
			if (_impl == null)
			{
				_impl = LoaderCore.getInstance();
			}
			
			return _impl;
		}
		
		
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		/**
		 * 
		 * @return 
		 */
		public static function get maxConnections():uint
		{
			return impl.maxConnections;
		}
		
		public static function set maxConnections(value:uint):void
		{
			if (value < 1)
			{
				throw new Error("maxConnections can't less than 1");
			}
			
			impl.maxConnections = value;
		}

		
		/**
		 * 
		 * @return 
		 */
		public static function get activeCount():uint
		{
			return impl.activeCount;
		}

		
		/**
		 * 
		 * @return 
		 */
		public static function get connectedCount():uint
		{
			return impl.connectedCount;
		}
		
		/**
		 * 
		 * @return 
		 */
		public static function get networkSpeed():Number
		{
			return impl.networkSpeed;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		public static function append(loader:LoaderItem):LoaderItem
		{
			return impl.append(loader);
		}
		
		public static function prepend(loader:LoaderItem):LoaderItem
		{
			return impl.prepend(loader);
		}
		
		public static function insert(loader:LoaderItem, index:uint = 999999999):LoaderItem
		{
			return impl.insert(loader, index);
		}
		
		public static function load():void
		{
			impl.load();
		}
		
		public static function cancel():void
		{
			impl.cancel();
		}


		
	}
}
